<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>lunar-道历的实例化</title>
<meta name="keywords" content="lunar,阳历,阴历,公历,农历,佛历,道历" />
<meta name="description" content="lunar是一个无依赖的支持阳历、阴历、佛历和道历的日历工具库。" />
<meta name="author" content="6tail" />
<link rel="stylesheet" href="common.css">
<link rel="stylesheet" href="highlight.min.css">
<link rel="stylesheet" href="markdown.css">
<link rel="stylesheet" href="page.css">
</head>
<body>
<div class="article">
<textarea class="md">
## 实例化

道历的实例化有以下几种方式：

1. Tao.fromYmd(year, month, day)
> 指定<code>道历年(数字)</code>、<code>道历月(数字)</code>、<code>道历日(数字)</code>生成道历对象。注意道历月和道历日与阴历相同。

2. Tao.fromYmdHms(year, month, day, hour, minute, second)
> 指定<code>道历年(数字)</code>、<code>道历月(数字)</code>、<code>道历日(数字)</code>、<code>阳历小时(数字)</code>、<code>阳历分钟(数字)</code>、<code>阳历秒钟(数字)</code>生成道历对象。注意道历月和道历日与阴历相同。

3. Tao.fromLunar(lunar)
> 指定<code>阴历对象(lunar)</code>生成道历对象

### 示例代码
<div class="codes">
  <a class="active" href="javascript:void(0);">javascript</a>
  <a href="javascript:void(0);">java</a>
  <a href="javascript:void(0);">csharp</a>
  <a href="javascript:void(0);">php</a>
  <a href="javascript:void(0);">python</a>
  <a href="javascript:void(0);">go</a>
</div>
<div id="javascript">

    var d = Tao.fromLunar(Lunar.fromDate(new Date()));
    console.log(d);
    console.log(d.toFullString());
</div>
<div id="java" style="display:none">

    Tao d = Tao.fromLunar(Lunar.fromDate(new Date()));
    System.out.println(d);
    System.out.println(d.toFullString());
</div>
<div id="csharp" style="display:none">

    Tao d = Tao.fromLunar(Lunar.fromDate(new Date()));
    Console.WriteLine(d);
    Console.WriteLine(d.toFullString());
</div>
<div id="php" style="display:none">

    $d = Tao::fromLunar(Lunar::fromDate(new DateTime()));
    echo $d."\n";
    echo $d->toFullString()."\n";
</div>
<div id="python" style="display:none">

    d = Tao.fromLunar(Lunar.fromDate(datetime.now()))
    print d
    print d.toFullString()
</div>
<div id="go" style="display:none">

    d := calendar.NewTaoFromLunar(calendar.NewLunarFromDate(time.Now()))
    fmt.Println(d)
    fmt.Println(d.ToFullString())
</div>

### 输出

</textarea>
<div id="output"></div>
</div>
<script src="libs/jquery.min.js"></script>
<script src="libs/highlight.min.js"></script>
<script src="libs/marked.min.js"></script>
<script src="common-source.js"></script>
<script src="lunar.js"></script>
<script>
mdr('.md');
</script>
<script>
var d = Tao.fromLunar(Lunar.fromDate(new Date()));
output(d);
output(d.toFullString());
</script>
</body>
</html>